﻿//-----------------------------------------------------------------------
// <copyright file="Category.cs" company="Transilvania University of Brasov">
//     Copyright (c) Nagy Robert. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DomainModel
{
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

    /// <summary>
    /// Describes the Category entity.
    /// </summary>
    public class Category
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Category"/> class.
        /// </summary>
        public Category()
        {
            this.ParentList = new List<Category>();
            this.ChildList = new List<Category>();
            this.ProductList = new List<DTOProduct>();
        }

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [Key]
        [RangeValidator(1, RangeBoundaryType.Inclusive, int.MaxValue, RangeBoundaryType.Inclusive, ErrorMessage = "Id must be at least {3}.")]
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [NotNullValidator(ErrorMessage = "Name cannot be null.")]
        [StringLengthValidator(2, 50, ErrorMessage = "Name length must be between 2 and 50 characters long.")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the parent list.
        /// </summary>
        [NotNullValidator(ErrorMessage = "ParentList cannot be null.")]
        public List<Category> ParentList { get; set; }

        /// <summary>
        /// Gets or sets the child list.
        /// </summary>
        [NotNullValidator(ErrorMessage = "ChildList cannot be null.")]
        public List<Category> ChildList { get; set; }

        /// <summary>
        /// Gets or sets the product list.
        /// </summary>
        [NotNullValidator(ErrorMessage = "ProductList cannot be null.")]
        public List<DTOProduct> ProductList { get; set; }
    }
}
